﻿<%@page pageEncoding="utf-8" %>
<%@include file="/util/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <%@include file="../common/head.jsp" %>

    <script language="javascript" type="text/javascript">
            //保存成功的提示信息
            function showResult() {
                showResultDiv(true);
                window.setTimeout("showResultDiv(false);", 3000);
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }

            //显示选填的信息项
            function showOptionalInfo(imgObj) {
                var div = document.getElementById("optionalInfo");
                if (div.className == "hide") {
                    div.className = "show";
                    imgObj.src = "../images/hide.png";
                }
                else {
                    div.className = "hide";
                    imgObj.src = "../images/show.png";
                }
            }
           jQuery.validator.addMethod("idlength",function(value,element){
           	return this.optional(element)||idlength(value);
           });
    
            function idlength(value){
            	return value.length==18;
            }
            function uniqueName(){
            return $("#loginName").remote('verifyName',
            '账号名称已被占用',$('#login_name_msg'));
            }
            $(function(){
            $("#idcardNo").blur(function(){
            	var val = $('#actidcardNo').val();
            	var date=val.substring(6, 10) + "-" + 
            	val.substring(10, 12) + "-" + 
            	val.substring(12, 14);
            	if(date.length<10) date="";
            	$('#birthday').val(date);
            });
            	$("#accountForm").validate({
            		rules:{
            		"act.realName":"required",
            		"act.idcardNo":{required:true,idlength:true},
            		"act.loginName":{required:true},
            		"act.loginPassword":"required",
            		"confirm_pwd":{required:true,equalTo:"#loginPassword"},
            		"act.telephone":"required",
            		"idcardNo":{idlength:true}
            		},messages:{
            		"act.realName":"请填写姓名",
            		"act.idcardNo":{required:"请填写身分证号码",idlength:"身分证号必须是18位"},
            		"act.loginName":{required:"请填写登录账号"},
            		"act.loginPassword":"请填写密码",
            		"confirm_pwd":{required:"请填写确认密码",equalTo:"两次密码必须相同"},
            		"act.telephone":"请填写电话",
            		"idcardNo":"身分证号必须是18位"
            		},errorPlacement:function(error,element) {
            		 error.appendTo(element.siblings(":last").addClass("error_msg"));
            		 },success:function(label,element){
            		 	$(element).siblings(":last").removeClass("error_msg").empty();
            		 }
            	});
            	function submitAccount(){
            		var b=$("#accountForm").submitForm("save",
            			'保存失败，该身份证已经开通过账务账号！','保存成功!',$("#save_result_info"));
            			if(b){
            				$('#save_result_info').attr("class","save_success");
            			}else{
            				$('#save_result_info').attr("class","save_fail");
            			}
            			showResult();
            	}
            	$("#save").click(function(){
            		if($("#accountForm").valid()&&uniqueName()){
            			submitAccount();
            		}
            	});
            	
            });
     </script>
    
    <body>
        <%@include file="../common/top.jsp"%>
        
        <div id="main">       
            <!--保存成功或者失败的提示消息-->     
            <div id="save_result_info" class="save_fail">保存失败，该身份证已经开通过账务账号！</div>
            <form action="#" method="post" class="main_form" id="accountForm">
                <!--必填项-->
                <div class="text_info clearfix"><span>姓名：</span></div>
                <div class="input_info">
                    <input type="text" name="act.realName" />
                    <span class="required">*</span>
                    <div class="validate_msg_long"></div>
                </div>
                <div class="text_info clearfix"><span>身份证：</span></div>
                <div class="input_info">
                    <input type="text" name="act.idcardNo"	id="actidcardNo" />
                    <span class="required">*</span>
                    <div class="validate_msg_long"></div>
                </div>
                <div class="text_info clearfix"><span>登录账号：</span></div>
                <div class="input_info">
                    <input type="text" name="act.loginName" id="loginName"/>
                    <span class="required">*</span>
                    <div class="validate_msg_long" id="login_name_msg"></div>
                </div>
                <div class="text_info clearfix"><span>密码：</span></div>
                <div class="input_info">
                    <input type="password"  name="act.loginPassword" id="loginPassword"/>
                    <span class="required">*</span>
                    <div class="validate_msg_long"></div>
                </div>
                <div class="text_info clearfix"><span>重复密码：</span></div>
                <div class="input_info">
                    <input type="password"  name="confirm_pwd"/>
                    <span class="required">*</span>
                    <div class="validate_msg_long"></div>
                </div>     
                <div class="text_info clearfix"><span>电话：</span></div>
                <div class="input_info">
                    <input type="text" name="act.telephone"class="width200"/>
                    <span class="required">*</span>
                    <div class="validate_msg_medium"></div>
                </div>                
                <!--可选项-->
                <div class="text_info clearfix"><span>可选项：</span></div>
                <div class="input_info">
                    <img src="../images/show.png" alt="展开" onclick="showOptionalInfo(this);" />
                </div>
                <div id="optionalInfo" class="hide">
                    <div class="text_info clearfix"><span>推荐人身份证号码：</span></div>
                    <div class="input_info">
                        <input type="text" name="idcardNo"/><span></span>
                        <div class="validate_msg_long"></div>
                    </div>
                    <div class="text_info clearfix"><span>生日：</span></div>
                    <div class="input_info">
                        <input type="text" name="act.birthdate"readonly class="readonly" id="birthday"/>
                    </div>
                    <div class="text_info clearfix"><span>Email：</span></div>
                    <div class="input_info">
                        <input type="text" name="act.email" class="width350"/>
                        <div class="validate_msg_tiny"></div>
                    </div> 
                    <div class="text_info clearfix"><span>职业：</span></div>
                    <div class="input_info">
                        <select name="act.occupation">
                        			<option value="">-请选择-</option>
                            <option value="干部">干部</option>
                            <option value="学生">学生</option>
                            <option value="技术人员">技术人员</option>
                            <option value="其他">其他</option>
                        </select>                        
                    </div>
                    <div class="text_info clearfix"><span>性别：</span></div>
                    <div class="input_info fee_type">
                        <input type="radio" name="act.gender" value="0"id="female" />
                        <label for="female">女</label>
                        <input type="radio" name="act.gender" value="1" id="male" />
                        <label for="male">男</label>
                    </div> 
                    <div class="text_info clearfix"><span>通信地址：</span></div>
                    <div class="input_info">
                        <input type="text" name="act.mailaddress"class="width350"/>
                        <div class="validate_msg_tiny">50长度以内</div>
                    </div> 
                    <div class="text_info clearfix"><span>邮编：</span></div>
                    <div class="input_info">
                        <input type="text" name="act.zipcode"/>
                        <div class="validate_msg_long">6位数字</div>
                    </div> 
                    <div class="text_info clearfix"><span>QQ：</span></div>
                    <div class="input_info" >
                        <input type="text" name="act.qq"/>
                        <div class="validate_msg_long">5到13位数字</div>
                    </div>                
                </div>
                <!--操作按钮-->
                <div class="button_info clearfix">
                    <input type="button" id="save" value="保存" class="btn_save" />
                    <input type="button" value="取消" class="btn_save" onclick="location='list?shidcardNo=${shidcardNo }&shrealName=${shrealName }&shloginName=${shloginName}&shstatus=${shstatus}&page=${page}'"/>
                </div>
            </form>  
        </div>
        
    	<%@include file="../common/bottom.jsp"%>
    </body>
</html>
